unit UMain;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  ProEvent = procedure() of object;

  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    procedure BBB();
    { Private declarations }
  public
    { Public declarations }
  end;

  procedure AAAEvent(EventID: Integer; sEvent: ProEvent);

var
  Form1: TForm1;

implementation

{$R *.dfm}


procedure AAAEvent(EventID: Integer; sEvent: ProEvent);
var
  hDLL: THandle;
  MyProc: procedure(EventID: Integer; sEvent: ProEvent);
begin
  try
    hDLL := LoadLibrary(PChar(ExtractFilePath(Application.ExeName) + 'PDLL.dll'));
    if hDLL = 0 then
    begin
      exit;
    end;
    @myProc := GetProcAddress(hDLL, 'AAAEvent');
    if Assigned(myProc) then
      myProc(EventID,sEvent);
    MyProc := nil;
  except
    MyProc := nil;
  end;
end;  

{ TForm1 }

procedure TForm1.BBB();
begin
  Application.MessageBox('ok','EXE');
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  uMain.AAAEvent(1,BBB);
end;

end.
